<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>DOM Manipulation Example</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
    </style>
</head>
<body>
    <div style="height: 500px; background-color: red;"></div>
    <div style="height: 800px; width: 1200px; background-color: aqua;"></div>
</body>
</html>
    <script>
    //返回某个网页元素的总高度
    console.log(document.documentElement.scrollHeight);
    //返回网页视口的总宽度
    console.log(document.documentElement.scrollWidth);

    // 表示网页元素的水平滚动条想右侧滚动的像素数量
    document.body.onscroll = function () {
        //到左边的滚动距离
        console.log(document.documentElement.scrollLeft);
        //到顶部的滚动距离
        console.log(document.documentElement.scrollTop);
    }
    </script>